﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class InvoiceProforma
    {
        public string company = string.Empty;///////////
        public string vessel_name = string.Empty;///////////
        public string voyage_no = string.Empty;///////////
        public DateTime invoice_date = DateTime.Today;///////////
        public decimal invoice_amount = 0;///////////
        public string invoice_type = string.Empty;///////////
        private CommissionInvoice ci;
        public InvoiceProforma(SqlDataReader rd)
        {
            company = rd["company"] is DBNull ? "" : rd["company"].ToString();
            vessel_name = rd["vessel_name"] is DBNull ? "" : rd["vessel_name"].ToString();
            voyage_no = rd["voyage_no"] is DBNull ? "" : rd["voyage_no"].ToString();
            invoice_date = rd["invoice_date"] is DBNull ? new DateTime(2000, 1, 1) : Convert.ToDateTime(rd["invoice_date"]);
            invoice_amount = rd["invoice_amount"] is DBNull ? 0 : Convert.ToDecimal(rd["invoice_amount"]);
            invoice_type = rd["invoice_type"] is DBNull ? "" : rd["invoice_type"].ToString();
        }

        public InvoiceProforma(CommissionInvoice ci)
        {
            company = ci.company;
            vessel_name = ci.vessel_name;
            voyage_no = ci.voyage_no;
            invoice_date = ci.invoice_date;
            invoice_amount = ci.invoice_amount;
            invoice_type = ci.invoice_type;
        }
        public override bool Equals(object obj)
        {
            InvoiceProforma pf = (InvoiceProforma)obj;

            if (pf == null) 
                return false;
            bool a = pf.company.Trim() == company.Trim();
            bool e = pf.vessel_name.Trim() == vessel_name.Trim();
            bool f = pf.voyage_no.Trim() == voyage_no.Trim();
            bool c = pf.invoice_date == invoice_date;
            bool b = pf.invoice_amount == invoice_amount;
            bool d = pf.invoice_type.Trim() == invoice_type.Trim();
            return a && b && c && d && e && f;
        }
    }
}
